/**
*      author: Y_Yao
*      created: 2024-11-22 11:46:56
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 7;
int q;
queue<int> que;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> q;
    int now = 1;
    for(int i = 1;i <= q;i++)
    {
        int oper;
        cin >> oper;
        if(oper == 1)
        {
            que.push(now);
        }
        else if(oper == 2)
        {
            int day;
            cin >> day;
            now += day;
        }
        else
        {
            int ans = 0;
            int h;
            cin >> h;
            while(!que.empty() && now - que.front() >= h)
            {
                ans++;
                que.pop();
            }
            cout << ans << endl;
        }
    }
    return 0;
}